package com.xyyl.patient.service.user;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.xyyl.patient.entity.order.PhoneOrder;
import com.xyyl.patient.entity.question.QuickQuestion;
import com.xyyl.patient.mapper.continuationonline.ContinuationOnlineMapper;
import com.xyyl.patient.mapper.order.SpeedPhoneOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xyyl.patient.core.support.Pager;
import com.xyyl.patient.mapper.order.PhoneOrderMapper;
import com.xyyl.patient.mapper.question.MyServiceMapper;
import com.xyyl.patient.mapper.question.QuickQuestionMapper;
import com.xyyl.patient.vo.GraphConsultMiniVo;

@Service("myserviceService")
public class MyserviceServiceImp implements MyserviceService {

	@Autowired
	private MyServiceMapper myServiceMapper;
	@Autowired
	private QuickQuestionMapper quickQuestionMapper;

	@Autowired
	private PhoneOrderMapper phoneOrderMapper;

	@Autowired
	private SpeedPhoneOrderMapper speedPhoneOrderMapper;

	@Autowired
	private ContinuationOnlineMapper continuationOnlineMapper;
	/*
	/*
	 * 获取服务列表service
	 * 1：快速提问；2：图文咨询；3：电话getIndexIM咨询 ,4急速电话,5在线续方
	 */
	@Override
	public List<GraphConsultMiniVo> queryUserServiceList(Pager pager,Integer type) {
		List<GraphConsultMiniVo> list =null;
		if(type==1){
			pager.getPageData().put("questionerid",pager.getPageData().get("userid"));
			list =quickQuestionMapper.queryForPage(pager);
		}else if (type==2){
			pager.getPageData().put("questionerid",pager.getPageData().get("userid"));
			list = myServiceMapper.queryForPage(pager);
		}else if (type==3){
			pager.getPageData().put("buyerid",pager.getPageData().get("userid"));
			list =phoneOrderMapper.queryForPage(pager);
		}else if (type==4){
			pager.getPageData().put("userid",pager.getPageData().get("userid"));
			list =speedPhoneOrderMapper.queryForPage(pager);
		}else if (type==5){
			pager.getPageData().put("userid",pager.getPageData().get("userid"));
			list =continuationOnlineMapper.queryForPage(pager);
		}

		
 		return list;
	}
	@Override
	public GraphConsultMiniVo queryUserServiceInfo(Integer id,Integer type){
		GraphConsultMiniVo  graphConsultMiniVo =null;
		try {
			if(type==1){

				QuickQuestion quickQuestion  =quickQuestionMapper.selectOne(id);
			}else if (type==2){

				graphConsultMiniVo = myServiceMapper.selectOne(id);
			}else if (type==3){
				//Map<String,Object> objectMap = new HashMap<>();
				PhoneOrder phoneOrder = phoneOrderMapper.selectOne(id);
				System.out.println(phoneOrder);
			}else if (type==4){
				graphConsultMiniVo =speedPhoneOrderMapper.selectOne(id);
			}else if (type==5){
				graphConsultMiniVo =continuationOnlineMapper.selectOne(id);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}


		return graphConsultMiniVo;
	}
	@Override
	public QuickQuestion quickQuestionInfo(Integer id) {
		QuickQuestion quickQuestion = quickQuestionMapper.selectOne(id);
		return quickQuestion;
	}
	@Override
	public Map<String, Object> getPharmacyInfo(Integer id){
		try {
			return myServiceMapper.getPharmacyInfo(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return myServiceMapper.getPharmacyInfo(id);
	}
}
